package cn.jinhe.doc.util;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;

public class NetSearcher {

    public static void main(String[] args) {
        // TODO code application logic here
        new NetSearcher();
    }
    
    public NetSearcher() {
        long start = System.currentTimeMillis();
        byte[] ip = {(byte)10,(byte)10,(byte)30,(byte)0};
        for(int i = 2; i < 254; i++) {
            try {
                ip[3] = (byte)i;
                Socket socket = new Socket();
                socket.connect(new InetSocketAddress(InetAddress.getByAddress(ip), 20000), 80);
                System.out.println("Server's address 10.10.30." + i);
                break;
            }catch(Exception e) {
                System.out.println("Server is not address 10.10.30." + i);
            }
        }
        System.out.println("Time takes " + (System.currentTimeMillis() - start) + " millis.");
    }
}